Mac PHPStorm 调试

安装xdebug

  1. 获取PHP安装信息
1
php -i

在终端运行以上语句并拷贝输出信息。

  1. 在浏览器中打开 https://xdebug.org/wizard.php 地址,并粘贴php信息。提交后,将出现安装指南的页面。

  2. 根据页面指示操作安装。

    1. Download xdebug-2.5.1.tgz

    2. Unpack the downloaded file with tar -xvzf xdebug-2.5.1.tgz

    3. Run: cd xdebug-2.5.1

    4. Run: phpize (See the FAQ if you don’t have phpize.

      As part of its output it should show:

      1
      2
      3
      4
      Configuring for:
      ...
      Zend Module Api No: 20131226
      Zend Extension Api No: 220131226

      If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.

    5. Run: ./configure

    6. Run: make

    7. Run: cp modules/xdebug.so /usr/local/Cellar/php56/5.6.30_6/lib/php/extensions/no-debug-non-zts-20131226

    8. Edit /usr/local/etc/php/5.6/php.ini and add the line
      zend_extension = /usr/local/Cellar/php56/5.6.30_6/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so

  1. 重启你的Web服务器(Apache、Nginx或者其他)。

PHPStorm配置

参见网上资料

疑难

  1. PHPStorm服务器的配置就是你原来的Web服务器地址和端口;
  2. xdebug的端口要与配置的一直,用默认的9000就可以了;
  3. 使用Chrome调试,请安装Xdebug helper以及JetBrains IDE Support插件;